【python】No such file or directory的解决方法 |
您所在的位置:网站首页 › no files or directory › 【python】No such file or directory的解决方法 |
利用python读取文件或者图片的时候,可能会出现读写文件出错。报错的信息如下: IOError: [Errno 2] No such file or directory。 通常情况下都是因为读取的文件路径不对找不到文件的原因。 解决方法: import os print os.getcwd() #打印出当前工作路径也可以修改当前的工作路径,方法如下: os.chdir('the dir which include the file a.txt') #修改当前工作目录 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |